package com.example.demo.entity.pojo.repository;

import com.baomidou.mybatisplus.annotation.TableName;
import com.example.demo.common.entity.enums.RepositoryTypeEnum;
import com.example.demo.common.entity.pojo.BaseEntityPoJo;
import com.example.demo.constant.Constant;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;

/**
 * 仓库实体.
 *
 * @author Mei Ruoxiao
 * @since 2020/9/11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
@ApiModel("仓库文件夹")
@TableName(value = "repository")
public class RepositoryPoJo extends BaseEntityPoJo {

    @ApiModelProperty(value = "名称")
    private String name;

    @ApiModelProperty(value = "父节点ID, 默认1", example = "1")
    private Long parentId;
    /**
     * {@link RepositoryTypeEnum#value()}
     */
    @ApiModelProperty(value = "文件夹类型 0-材料 1-成品 2-废品", example = "0")
    private int type;

    @ApiModelProperty(value = "全路径ID结构（到自己本身ID）", example = "如：10085,10086,10087")
    private String fullIds;

    public RepositoryPoJo(int type, long companyId) {
        this.type = type;
        this.parentId = Constant.SYSTEM_ID;
        setCompanyId(companyId);
    }

    public RepositoryPoJo(String name, int type, long parentId, long companyId) {
        this.name = name;
        this.type = type;
        this.parentId = parentId;
        setCompanyId(companyId);
    }

    public static RepositoryPoJo of(int type, long companyId) {
        return new RepositoryPoJo(type, companyId);
    }

    public static RepositoryPoJo of(String name, final int type, final long parentId, final long companyId) {
        return new RepositoryPoJo(name, type, parentId, companyId);
    }

}
